// pages/index/platform_activities/platform_activities.js
//获取应用实例
const app = getApp()
Page({

    /**
     * 页面的初始数据
     */
    data: {
        // winHeight:"",//窗口高度
        currentTab: 1, //预设当前项的值
        norecord: false,
        hiddenModal: true,
        companylistData: [],
        enterpriselistData: [],
        swiperHeader: '',
        IndividualCompany: [],
        banner: [],
        bannerIndex: null,
        duration: 0
    },
    listenerButton() {
        this.setData({
            hiddenModal: !this.data.hiddenModal
        })
    },
    listenerConfirm() {
        this.setData({
            hiddenModal: true
        })
    },
    listenerCancel() {
        this.setData({
            hiddenModal: true
        })
    },
    // 滚动切换标签样式
    switchTab: function(e) {
        this.setData({
            currentTab: e.detail.current
        });
        this.checkCor();
    },
    // 点击标题切换当前页时改变样式
    swichNav: function(e) {
        var cur = e.target.dataset.current,
            _this = this;
        if (this.data.currentTab == cur) { return false; } else {
            this.getlistData(cur);
            this.setData({
                currentTab: cur
            })
        }
    },
    //信息发布数据请求
    getlistData(type) {
        let _this = this;
        app.util.ajax({
            url: 'Release/index',
            data:{
                type:type
            },
            success: function(res) {
                // if (res.company || res.enterprise) {
                    // let aa = res.company;
                    // var str = [];
                    // for (let i = 0; i < aa.length; i++) {
                    //     let bb = aa[i].company;
                    //     for (let j = 0; j < bb.length; j++) {
                    //         str.push(bb[j]);
                    //     }
                    // }
                    _this.setData({
                        companylistData: res.company || [],
                        enterpriselistData: res.enterprise || [],
                        // IndividualCompany: str
                    })
                // }
            }
        })
    },
    //通知他
    getnotice(e) {
        console.log(e,'12313123')
        let _this = this;
        let user_id = app.globalData.userInfo.user_id;
        let state = app.globalData.userInfo.state;
        let member_id = e.detail.target.dataset.member_id;
        let id = e.detail.target.dataset.rel_id;
        let formId = e.detail.formId;
        app.util.ajax({
            url: 'Release/tz_add',
            data: {
                user_id: user_id,
                rel_id: id,
                member_id: member_id,
                state: state,
                formId:formId
            },
            success: function(res) {
                wx.showToast({
                    title: '通知成功',
                    icon: 'success',
                    duration: 2000
                })
            }
        })
    },

    //查看名片
    checkCard(e) {
        let id = e.currentTarget.dataset.id,
            type = e.currentTarget.dataset.type;
        wx.navigateTo({
            url:"/pages/user/personal/personal?id="+id+'&state='+type
        })
    },
    // 查看详细内容
    seeContentDetail:function(e){
        let eTraget = e.currentTarget.dataset,
            listId = eTraget.listId,
            index = eTraget.index,
            type = eTraget.type,
            showData = type == '1' ? this.data.companylistData[index] : this.data.enterpriselistData[index],
            _this = this;
        wx.showModal({
            title:showData.title,
            content:showData.content,
            showCancel:false
        })
    },
    // 显示轮播
    showBanner: function (e) {
        this.setData({
            banner: e.currentTarget.dataset.banner
        })
        this.setData({
            bannerIndex: e.currentTarget.dataset.index
        })
        this.setData({
            duration: 350
        })
    },
    // 隐藏轮播
    hideBanner: function () {
        this.setData({
            banner: []
        })
        this.setData({
            bannerIndex: null
        })
        this.setData({
            duration: 0
        })
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function(options) {
        
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function() {
        var that = this;
        this.getlistData(this.data.currentTab);
    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function() {

    },

    /**
     * 用户点击右上角分享
     */
    // 分享
    onShareAppMessage(res) {
        return {
            title: '广州大学校友会校友企业家专委会',
            path: '/pages/index/index'
        }
    },
})